lottery_n=55;

%%%%%%%%%%%%%%%%%%%%%%%%%% Time Choices %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

load temporal_task_info
time_choice_n=size(choices,1);

% choice 1 is the sooner one
% $ in first option
x1=choices(:,1)';
% years from now that the $ will be received
t1=choices(:,2)';
% choice 2 is the more distant one
% $ in second option
x2=choices(:,3)';
% years from now that the $ will be received
t2=choices(:,4)';

%%%%%%%%%%%%%%%%%%%%%%%%%%% Simulation Parameters %%%%%%%%%%%

%%% Scaling factor on simulation (sample size=1224 individuals*pop_scale)
pop_scale=200;
ind_n=1224*pop_scale;




%%% Additional simulation parameters
draw_n=1;
per_n=1;
char_n=1;
err_type_id=1
err_type_i=1;
error_mag_id=1;

%%% Individual identifier
ind_id_unique=1:1224;
ind_id_unique=kron(ind_id_unique', ones(per_n*pop_scale,1));

%observables going into the deterministic part of a factor
X_s=kron(X_s, ones(per_n*pop_scale,1));
X_ind_s=kron(X_s, ones(per_n*draw_n,1));

%%%%%%%%%%%%%%%%%%%%%%%% Estimated structural coefficients

%%% Estimated standard deviations of the orthogonal components of the factors
error_mag_i=est_sd;
%%% estimated standard deviation on the error of the continuous measure
%%% (numeracy score in congitive factor)
error_mag_cont=max(est_sd_cont);
%%% coeffs on the observables going into the deterministic part of a
%%% factor (each factor has its own set of coeffs)
alpha=est_alpha;
% factor loadings of the various measures - 1st loading normalized to 1 for
% each factor
load=est_load;
%%% Estimated factor intercepts
f_mean=est_f_mean;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


j=0;
for i=1:factor_n
    rng('shuffle');
    run ind_data_gen
    %%% simulated factors
    factors(:,i)=X_f; 
    j=j+c_char_n(i);
end;



